﻿@using Smartstore.Web.Models.Customers;

@model CustomerOrderListModel

@{
    Assets.AppendTitleParts(T("PageTitle.Account"));

    Layout = "_MyAccount";
    ViewBag.PageClassToken = "orders";
    ViewBag.PageTitle = T("Account.CustomerOrders").Value;
}

@if (Model.RecurringPayments.Count > 0)
{
    <partial name="RecurringPayments" />
}

@if (Model.Orders.Count == 0)
{
    <div class="alert alert-warning" role="status" aria-live="polite">
        @T("Account.CustomerOrders.NoOrders")
    </div>
    return;
}

<ul class="order-list list-unstyled" aria-labelledby="myaccount-header">
    @foreach (var order in Model.Orders)
    {
        <li class="order-item mb-3" aria-labelledby="order-title@(order.Id)">
            <div class="card">
                <div class="card-body">
                    <div id="order-title@(order.Id)" class="card-title h5 mb-4">
                        @T("Order.Order#"): @order.OrderNumber
                    </div>
                    <dl class="row mb-0" role="presentation">
                        <dt class="col-sm-3 fwn text-muted">@T("Order.OrderStatus")</dt>
                        <dd class="col-sm-9">@order.OrderStatus</dd>
                        <dt class="col-sm-3 fwn text-muted">@T("Order.OrderDate")</dt>
                        <dd class="col-sm-9">
                            <time asp-for="@order.CreatedOn"></time>
                        </dd>
                        <dt class="col-sm-3 fwn text-muted">@T("Order.OrderTotal")</dt>
                        <dd class="col-sm-9 price">
                            <data asp-for="@order.OrderTotal"></data>
                        </dd>
                    </dl>
                </div>

                <div class="card-footer d-flex p-2">
                    <a asp-action="Details" asp-controller="Order" asp-route-id="@order.Id" class="btn btn-light btn-sm btn-flat" rel="nofollow">
                        <i class="far fa-rectangle-list" aria-hidden="true"></i>
                        <span>@T("Order.OrderDetails")</span>
                        <span class="sr-only"> @order.OrderNumber</span>
                    </a>
                    @if (order.IsReturnRequestAllowed)
                    {
                        <a asp-action="ReturnRequest" asp-controller="ReturnRequest" asp-route-id="@order.Id" class="btn btn-light btn-sm btn-flat" rel="nofollow">
                            <i class="fa fa-reply" aria-hidden="true"></i>
                            <span>@T("Account.CustomerOrders.ReturnItems")</span>
                            <span class="sr-only"> @order.OrderNumber</span>
                        </a>
                    }
                </div>
            </div>
        </li>
    }
</ul>

<div sm-if="Model.Orders.TotalPages > 1" class="mt-1">
    <pagination sm-list-items="Model.Orders" sm-query-param="page" id="paginator" />
</div>